Public Class RelAnaliticoAuto
    Public i As Integer

    Private Sub RelAnaliticoAuto_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        btnGerar.Enabled = False
        CBAnoFinal.Enabled = False
        CBAnoInicial.Text = "1939"
        i = 1939
        For Me.i = 1939 To CInt(Today.Year)
            CBAnoInicial.Items.Add(CStr(i))
        Next
        CBAnoInicial.SelectedIndex = 0
        CBAnoFinal.SelectedIndex = CBAnoFinal.Items.Count - 1
    End Sub

    Private Sub btnCancelar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Close()
    End Sub

    Private Sub CBAnoInicial_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CBAnoInicial.SelectedIndexChanged
        CBAnoFinal.Enabled = True
        CBAnoFinal.Items.Clear()
        CBAnoFinal.Text = CStr(Today.Year)
        CBAnoFinal.Items.Add(CStr(Today.Year))
        For Me.i = CInt(CBAnoInicial.Text) To CInt(Today.Year) - 1
            btnGerar.Enabled = True
            CBAnoFinal.Items.Add(CStr(i))
        Next
    End Sub

    Private Sub btnGerar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGerar.Click
        Dim str As String = String.Format("SELECT tblAuto.*,tblModeloAuto.descricaomodeloAuto,tblMontadoraAuto.descricaomontadoraAuto,tblCliente.nomeCliente,tblCorAuto.descricaocorAuto,tblCombustivel.descricaoCombustivel,tblEstado.descricaoEstado FROM ((((((tblAuto INNER JOIN tblModeloAuto ON tblModeloAuto.codmodeloAuto = tblAuto.codmodeloAuto) INNER JOIN tblEstado ON tblEstado.codEstado = tblAuto.codEstado)INNER JOIN tblMontadoraAuto ON tblMontadoraAuto.codmontadoraAuto = tblAuto.codmontadoraAuto) INNER JOIN tblCliente ON tblCliente.codCliente = tblAuto.codCliente) INNER JOIN tblCorAuto ON tblCorAuto.codCorAuto = tblAuto.codCorAuto) INNER JOIN tblCombustivel ON tblCombustivel.codCombustivel = tblAuto.codCombustivel) WHERE tblAuto.anofabricacaoAuto BETWEEN {0} AND {1}" _
                                          , CStr(CBAnoInicial.Text) _
                                          , CStr(CBAnoFinal.Text))
        VisualizadorRelatorio.gerarRelatorio(str, "tblAuto" _
                                             , Config.DiretorioAplicacao & "/../../../Relatorio/relatorioAnaliAuto.rpt")

    End Sub

    Private Sub btnCancelar_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancelar.Click
        Me.Dispose()
    End Sub
End Class